package cn.kkdlk.generate.dxf.util;

import java.io.File;

public class FileUtil {

	public static void deleteFile(File file) {
		if (file.exists()) {
			// dir type
			if (file.isDirectory()) {
				File[] files = file.listFiles();
				if (files == null || files.length == 0) {
					if (!file.delete()) {
						System.err.println("delete dir fail," + file.getAbsolutePath());
					}
				} else {
					System.err.println("can't delete a not empty dir," + file.getAbsolutePath());
				}
			} else { // file type
				if (!file.delete()) {
					System.err.println("delete File fail" + file.getAbsolutePath());
				}
			}
		} else {
			System.err.println("file not exists or not's a file" + file.getAbsolutePath());
		}
	}

}
